package com.briup.day13;

/**
 * @author ThinkBook
 */
public class Test03_Poly {
    //多态测试
    public static void main(String[] args) {
        Point p1 = new Point(2,4);
        p1.show();

        System.out.println("------------");

        p1 = new Circle(1,2,2.5);
        p1.show();

        System.out.println("------------");
        p1 = new TCircle(0,3,1.5,3.1);
        p1.show();
    }
}

//定义父类 Point: x,y show()
class Point{
    public int x;
    public int y;

    public Point() {

    }

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
    public void show(){
        System.out.println("Point{x: " + x +
                ", y: " + y + "}");
    }
}
//定义子类 Circle: radius show()
class Circle extends Point{
    private double radius;

    public Circle(){

    }
    public Circle(int x,int y,double radius) {
        super(x,y);
        this.radius = radius;
    }
    @Override
    public void show(){
        System.out.println("Circle{x: " + x +
                ", y: " + y + ", radius: " +
                radius + "}");
    }
}

//定义子类 TCircle: xRadius yRadius show()
class TCircle extends Point {
    private double xRadius;
    private double yRadius;

    //构造方法
    public TCircle() {
    }
    public TCircle(int x, int y, double xRadius, double yRadius) {
        super(x, y);
        this.xRadius = xRadius;
        this.yRadius = yRadius;
    }

    //重写从父类继承的方法
    @Override
    public void show() {
        System.out.println("TCircle{x: " + x +
                ", y: " + y + ", xRadius: " +
                xRadius + ", yRadius: " + yRadius + "}");
    }
}